package main

import (
	"github.com/gorilla/mux"
	"goblog/app/http/middlewares"
	"goblog/bootstrap"
	"goblog/config"
	config2 "goblog/pkg/config"
	"log"
	"net/http"
)

var router *mux.Router

func init() {
	// 初始化配置信息
	config.Initialize()
}

// main 主程序路口
func main() {

	// 数据库初始化
	bootstrap.SetupDB()
	// 路由初始化
	router = bootstrap.SetupRoute()

	// 监听端口
	err := http.ListenAndServe(":"+config2.GetString("app.port"), middlewares.RemoveTrailingSlash(router))
	if err != nil {
		log.Fatal("Server Run Failed.:", err)
	}
}
